package com.jwds.digital.bios.business.core.infrastructure.dto.dispatch.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.dispatch.DispatchReceivingMaterialsReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.dispatch.DispatchReceivingMaterialsRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.dispatch.DispatchReceivingMaterials;
import java.util.Objects;

/**
 * DispatchReceivingMaterials DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class DispatchReceivingMaterialsAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static DispatchReceivingMaterials dto2entity(DispatchReceivingMaterialsReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    DispatchReceivingMaterials entity = new DispatchReceivingMaterials();
    entity.setWarehouseCode(dto.getWarehouseCode());
    entity.setWarehouseName(dto.getWarehouseName());
    entity.setDestPointion(dto.getDestPointion());
    entity.setDestDevice(dto.getDestDevice());
    entity.setSendTime(dto.getSendTime());
    entity.setTaskNo(dto.getTaskNo());
    entity.setWorkType(dto.getWorkType());
    entity.setHeapCode(dto.getHeapCode());
    entity.setPlanWeight(dto.getPlanWeight());
    entity.setSupplier(dto.getSupplier());
    entity.setLineUpVehicles(dto.getLineUpVehicles());
    entity.setVehicles(dto.getVehicles());
    entity.setMaterialCode(dto.getMaterialCode());
    entity.setMaterialName(dto.getMaterialName());
    entity.setId(dto.getId());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static DispatchReceivingMaterials dto2entity(DispatchReceivingMaterialsReqDTO dto, DispatchReceivingMaterials entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getWarehouseCode())) {
      entity.setWarehouseCode(dto.getWarehouseCode());
    }
    if(Objects.nonNull(dto.getWarehouseName())) {
      entity.setWarehouseName(dto.getWarehouseName());
    }
    if(Objects.nonNull(dto.getDestPointion())) {
      entity.setDestPointion(dto.getDestPointion());
    }
    if(Objects.nonNull(dto.getDestDevice())) {
      entity.setDestDevice(dto.getDestDevice());
    }
    if(Objects.nonNull(dto.getSendTime())) {
      entity.setSendTime(dto.getSendTime());
    }
    if(Objects.nonNull(dto.getTaskNo())) {
      entity.setTaskNo(dto.getTaskNo());
    }
    if(Objects.nonNull(dto.getWorkType())) {
      entity.setWorkType(dto.getWorkType());
    }
    if(Objects.nonNull(dto.getHeapCode())) {
      entity.setHeapCode(dto.getHeapCode());
    }
    if(Objects.nonNull(dto.getPlanWeight())) {
      entity.setPlanWeight(dto.getPlanWeight());
    }
    if(Objects.nonNull(dto.getSupplier())) {
      entity.setSupplier(dto.getSupplier());
    }
    if(Objects.nonNull(dto.getLineUpVehicles())) {
      entity.setLineUpVehicles(dto.getLineUpVehicles());
    }
    if(Objects.nonNull(dto.getVehicles())) {
      entity.setVehicles(dto.getVehicles());
    }
    if(Objects.nonNull(dto.getMaterialCode())) {
      entity.setMaterialCode(dto.getMaterialCode());
    }
    if(Objects.nonNull(dto.getMaterialName())) {
      entity.setMaterialName(dto.getMaterialName());
    }
    if(Objects.nonNull(dto.getId())) {
      entity.setId(dto.getId());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static DispatchReceivingMaterialsRespVO entity2dto(DispatchReceivingMaterials entity) {
    if (entity == null) {
      return null;
    }
    DispatchReceivingMaterialsRespVO dto = new DispatchReceivingMaterialsRespVO();
    dto.setId(entity.getId());
    dto.setWarehouseCode(entity.getWarehouseCode());
    dto.setWarehouseName(entity.getWarehouseName());
    dto.setOriginPointion(entity.getOriginPointion());
    dto.setDestPointion(entity.getDestPointion());
    dto.setDestDevice(entity.getDestDevice());
    dto.setSendTime(entity.getSendTime());
    dto.setTaskNo(entity.getTaskNo());
    dto.setWorkType(entity.getWorkType());
    dto.setHeapCode(entity.getHeapCode());
    dto.setPlanWeight(entity.getPlanWeight());
    dto.setSupplier(entity.getSupplier());
    dto.setLineUpVehicles(entity.getLineUpVehicles());
    dto.setVehicles(entity.getVehicles());
    dto.setMaterialCode(entity.getMaterialCode());
    dto.setMaterialName(entity.getMaterialName());
    dto.setCreateUser(entity.getCreateUser());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyUser(entity.getModifyUser());
    dto.setModifyTime(entity.getModifyTime());
    dto.setId(entity.getId());
    return dto;
  }

}
